package com.mystudy.leetcode.problem.string.p_657;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author 周志龙
 * @Email 15216876513@163.com
 * @Date on 2019/7/10 23:37
 * @Description 机器人能否返回原点
 */
public class Solution {
    private static final Logger LOGGER = LoggerFactory.getLogger(Solution.class);
    @Test
    public void test(){
        boolean ud = judgeCircle("LL");
        LOGGER.debug("ud = [ {} ]",ud);

    }

    public boolean judgeCircle(String moves) {
        char[] chars = moves.toCharArray();
        int ucount = 0;
        int dcount = 0;
        int lcount = 0;
        int rcount = 0;
        for (char move : chars) {
            switch (move) {
                case 'U':
                    ucount++;
                    break;
                case 'D':
                    dcount++;
                    break;
                case 'L':
                    lcount++;
                    break;
                case 'R':
                    rcount++;
                    break;
            }
        }
        if(ucount == dcount && lcount==rcount){
            return true;
        }
        return false;
    }
}
